]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shellDBus: Return error on invalid app IDs
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 8 Jan 2019 21:03:13 +0000 (22:03 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 25 Jan 2022 19:18:35 +0000 (20:18 +0100)
When passing an invalid or unknown app ID to FocusApp(), we currently
open the app picker and silently fail to select the desired app.
Instead of half-working like that, make it clear that the argument
was invalid by returning an appropriate error. (It's easy to get the
ID wrong, as unlike appstream/flatpak IDs, we include the ".desktop"
suffix).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/337>

js/ui/shellDBus.js

index aeabe6d81e0cdfda848cee87be289d6fac7d35e6..39bba7aa342ef79ff2b3e52ce716c17c81931f82 100644 (file)
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported GnomeShell, ScreenSaverDBus */
 
-const { Gio, GLib, Meta } = imports.gi;
+const { Gio, GLib, Meta, Shell } = imports.gi;
 
 const Config = imports.misc.config;
 const ExtensionDownloader = imports.ui.extensionDownloader;
@@ -153,6 +153,15 @@ var GnomeShell = class {
             return;
         }
 
+        const appSys = Shell.AppSystem.get_default();
+        if (appSys.lookup_app(id) === null) {
+            invocation.return_error_literal(
+                Gio.DBusError,
+                Gio.DBusError.FILE_NOT_FOUND,
+                `No application with ID ${id}`);
+            return;
+        }
+
         Main.overview.selectApp(id);
         invocation.return_value(null);
     }